package com.jsnj33.pdaproject.utils;/**
 * 作者:33oa李国平 on 2017/6/2915:18
 */

import android.content.Context;
import android.widget.Toast;

/**
 * Created by 33oa on 2017/6/29.
 */
public class ToastUtil {
    //1.防止土司多次弹窗
    private static Toast toast;
    public static void showToast(Context context,String content) {
        if (toast == null) {
            toast = Toast.makeText(context,content,Toast.LENGTH_SHORT);
        } else {
            toast.setText(content);
        }
        toast.show();
    }

    public static void showGravityToast(Context context,String content,int gravity,int xOffset,int yOffset) {
        if (toast == null) {
            toast = Toast.makeText(context,content,Toast.LENGTH_SHORT);
            toast.setGravity(gravity,xOffset,yOffset);
        } else {
            toast.setText(content);
        }
        toast.show();
    }

    public static void showLongToast(Context context,String content) {
        if (toast == null) {
            toast = Toast.makeText(context,
                    content,
                    Toast.LENGTH_LONG);
        } else {
            toast.setText(content);
        }
        toast.show();
    }
    public static void showLongGravityToast(Context context,String content,int gravity,int xOffset,int yOffset) {
        if (toast == null) {
            toast = Toast.makeText(context,
                    content,
                    Toast.LENGTH_LONG);
            toast.setGravity(gravity,xOffset,yOffset);
        } else {
            toast.setText(content);
        }
        toast.show();
    }
}
